//
//  RealTimeDataTableViewCell.m
//  RTUApp
//
//  Created by 陈德军 on 2017/7/10.
//  Copyright © 2017年 陈德军. All rights reserved.
//

#import "RealTimeDataTableViewCell.h"


@interface RealTimeDataTableViewCell(){
    
}

@end

@implementation RealTimeDataTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


+ (instancetype)cellWithtableView:(UITableView *)tableview{
    static NSString *ID = @"cell";
    RealTimeDataTableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if(!cell)
    {
        cell = [[RealTimeDataTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.numberLabel = [UILabel new];
        self.numberLabel.size = CGSizeMake(40, 23);
        self.numberLabel.left = 5;
        self.numberLabel.centerY = self.contentView.centerY;
        self.numberLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.numberLabel];
        
        self.dateLabel = [UILabel new];
        self.dateLabel.numberOfLines = 0;
        self.dateLabel.size = CGSizeMake((kScreenWidth-40)/4, 42);
        self.dateLabel.left = self.numberLabel.right;
        self.dateLabel.centerY = self.contentView.centerY;
        self.dateLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.dateLabel];
        
        self.buriedDepthLabel = [UILabel new];
        self.buriedDepthLabel.size = CGSizeMake((kScreenWidth-40)/4, 23);
        self.buriedDepthLabel.left = self.dateLabel.right;
        self.buriedDepthLabel.centerY = self.contentView.centerY;
        self.buriedDepthLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.buriedDepthLabel];
        
        self.waterTemperatureLabel = [UILabel new];
        self.waterTemperatureLabel.size = CGSizeMake((kScreenWidth-40)/4, 23);
        self.waterTemperatureLabel.left = self.buriedDepthLabel.right;
        self.waterTemperatureLabel.centerY = self.contentView.centerY;
        self.waterTemperatureLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.waterTemperatureLabel];
        
        self.voltageLabel = [UILabel new];
        self.voltageLabel.size = CGSizeMake((kScreenWidth-40)/4, 23);
        self.voltageLabel.left = self.waterTemperatureLabel.right;
        self.voltageLabel.centerY = self.contentView.centerY;
        self.voltageLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.voltageLabel];
    }
    return self;
}

- (void)setModel:(RealTimeDataModel *)model{
    self.numberLabel.text = model.numberStr;
    self.dateLabel.text = model.dateStr;
    self.buriedDepthLabel.text = model.buriedDepthStr;
    self.waterTemperatureLabel.text = model.waterTemperatureStr;
    self.voltageLabel.text = model.voltageStr;
}

@end
